﻿#ifndef PRJ_MANAGER_TABLE_WIDGET_H
#define PRJ_MANAGER_TABLE_WIDGET_H

#include <QWidget>
#include "sqlite_manager.h"
#include "global_manager.h"
#include <QLabel>

namespace Ui {
class PrjManagerTableWidget;
}

class PrjManagerTableWidget : public QWidget
{
    Q_OBJECT

public:
    explicit PrjManagerTableWidget(QWidget *parent = nullptr);
    ~PrjManagerTableWidget();

signals:
    void prjDoubleClicked(QString prjName, QString uuid);

private slots:
    void onNewPrjBtnClicked();
    void onEditPrj(PrjTableData *data, int row);
    void onDeletePrj(PrjTableData *data, int row);

private:
    void initUi();
    void initEvents();
    /**
     * 清空项目信息表格
     */
    void clearPrjDataTable();
    void initPrjData();
    /**
     * 根据查询条件加载项目信息
     */
    void loadPrjDataOnPrjNameContainsText(QString text);
    void insertRow(QString uuid, QString prjName, QString prjDesc, QString createTime, QString lastModifyTime);
    bool insertNewPrj(QString uuid, QString prjName, QString prjDesc, QString createTime);

private:
    Ui::PrjManagerTableWidget *ui;
    SqliteManager               *m_sqlOperator;
};

#endif // PRJ_MANAGER_TABLE_WIDGET_H
